package main

import (
	"fmt"
	"strings"
)
import "unicode"

func main(){
	var password string
	fmt.Println("请输入密码：")
	fmt.Scan(&password)
	scord := condition1(password) + condition2(password) + condition3(password) + 2
	fmt.Printf("密码的安全分数是%d分",scord)

}

func condition1(password string) int {
	if(len(password) >= 8){
		return 1
	} else {
		return 0
	}
}

func condition2(password string) int {
	var lst [4]int
	for i := 0; i < len(password); i++ {
		if lst[0] + lst[1] + lst[2] + lst[3] >= 3 {
			return 1
		} else {
				switch {
				case unicode.IsDigit(rune(password[i])):
					lst[0] = 1
				case unicode.IsUpper(rune(password[i])):
					lst[1] = 1
				case unicode.IsLower(rune(password[i])):
					lst[2] = 1
				default:
					lst[3] = 1
				}
			}
		}
		return 0
	}

func condition3(password string) int {
	if len(password) < 6{
		return 0
	}
	for i := 0; i < len(password); i++{
		j := i+3
		if strings.Count(password,password[i:j]) >=2{
				return 0
			}
		}

	return 1
}